package com.tuliyou.controller;

import com.tuliyou.common.util.Result;
import com.tuliyou.dto.ScoreRankDTO;
import com.tuliyou.service.ScoreRankService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/score-ranks")
public class ScoreRankController {

    @Resource
    private ScoreRankService scoreRankService;

    @GetMapping("/rank")
    public Result<ScoreRankDTO> getRankByScore(
            @RequestParam(defaultValue = "2025") Integer statYear,
            @RequestParam Integer score){
        return scoreRankService.getRankByScore(statYear,score);
    }

    @GetMapping("/score")
    public Result<ScoreRankDTO> getScoreByRank(
            @RequestParam(defaultValue = "2025") Integer statYear,
            @RequestParam Integer rank){
        return scoreRankService.getScoreByRank(statYear,rank);
    }

}
